﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using DataHelper;
//工资银行账号
namespace DAL
{
   public class BankAccountDao
    {
        public bool Insert(SortedDictionary<string, string> sdList)
        {
            string strSQL = "if not exists (select * from Wage_BankAccount where EmpCode='" + sdList["EmpCode"] + "') begin  Insert Wage_BankAccount (EmpName,EmpCode,BankName,BankAccount) values ('" + sdList["EmpName"] + "','" + sdList["EmpCode"] + "','" + sdList["BankName"] + "','" + sdList["BankAccount"] + "') end else begin update Wage_BankAccount set BankName='" + sdList["BankName"] + "',BankAccount='" + sdList["BankAccount"] + "',EmpName='" + sdList["EmpName"] + "' Where EmpCode='" + sdList["EmpCode"] + "' end";
            return SQLHelper.ExecuteSql(strSQL);
        }


        public bool Update(SortedDictionary<string, string> sdList)
        {
            string strSQL = "update Wage_BankAccount set BankName='" + sdList["BankName"] + "',BankAccount='" + sdList["BankAccount"] + "',EmpName='" + sdList["EmpName"] + "' Where EmpCode='" + sdList["EmpCode"] + "'";
            return SQLHelper.ExecuteSql(strSQL);
        }

        public bool DeleteOneInfo(string empCode)
        {
            return SQLHelper.ExecuteSql("Delete from Wage_BankAccount Where EmpCode='" + empCode+"'");
        }
        //获取一条记录
        public DataTable GetOneInfo(string empCode)
        {
            return SQLHelper.ExecuteSqlGetDrToDt("Select * from Wage_BankAccount Where  EmpCode='" + empCode + "'");
        }

    }
}
